const key = getFilePathStore(import.meta.url)

export const useCoreBaseNavightionStore = defineStore(key, {
    state: () => ({
        title: "",
        haveLeftNav: false,
        haveRightNav: false,
        leftArrowClick: (() => { }),
        leftHasDot: false,
        rightArrowClick: (() => { }),
        rightHasDot: false,
        leftIconName: '',
        rightIconName: '',
    }),
    actions: {
        async setTitle(title: string) {
            this.title = title;
            return this;
        },
        async setHaveLeftIcon(haveLeftIcon: boolean) {
            this.haveLeftNav = haveLeftIcon;
            return this;
        },
        async setHaveRightIcon(haveRightIcon: boolean) {
            this.haveRightNav = haveRightIcon;
            return this;
        },
        async setLeftArrowClick(leftArrowClick: () => void) {
            this.leftArrowClick = leftArrowClick;
            return this;
        },
        async setLeftHasDot(leftHasDot: boolean) {
            this.leftHasDot = leftHasDot;
            return this;
        },
        async setRightArrowClick(rightArrowClick: () => void) {
            this.rightArrowClick = rightArrowClick;
            return this;
        },
        async setRightHasDot(rightHasDot: boolean) {
            this.rightHasDot = rightHasDot;
            return this;
        },
        async setLeftIconName(leftIconName: string) {
            this.leftIconName = leftIconName;
            return this;
        },
        async setRightIconName(rightIconName: string) {
            this.rightIconName = rightIconName;
            return this;
        },
        async bulidStore(
            title: string = "", haveLeftIcon: boolean = false, haveRightIcon: boolean = false,
            leftArrowClick: () => void = (() => { }), leftHasDot: boolean = false,
            rightArrowClick: () => void = (() => { }), rightHasDot: boolean = false,
            leftIconName: string = '', rightIconName: string = ''
        ) {
            await this.setTitle(title);
            await this.setHaveLeftIcon(haveLeftIcon);
            await this.setHaveRightIcon(haveRightIcon);
            await this.setLeftArrowClick(leftArrowClick);
            await this.setLeftHasDot(leftHasDot);
            await this.setRightArrowClick(rightArrowClick);
            await this.setRightHasDot(rightHasDot);
            await this.setLeftIconName(leftIconName);
            await this.setRightIconName(rightIconName);
            return this;
        },
        async initStore(){
            await this.setTitle("");
            await this.setHaveLeftIcon(false);
            await this.setHaveRightIcon(false);
            await this.setLeftArrowClick(() => { });
            await this.setLeftHasDot(false);
            await this.setRightArrowClick(() => { });
            await this.setRightHasDot(false);
            await this.setLeftIconName('');
            await this.setRightIconName('');
            return this;
        }
    },
    persist: {
        key: key,
        storage: sessionStorage
    }
})